cd /home/chess/chess
git pull
mvn clean package -Pproduct
cd /home/chess/chess/chess-service
\cp -rf ../environment/docker target
\cp -f target/chess.jar target/docker

#读取版本号
version=$(echo `awk '/<version>[^<]+<\/version>/{gsub(/<version>|<\/version>/,"",$1);print $1;exit;}' pom.xml` | tr '[A-Z]' '[a-z]')

#发布新副本（绿）
docker stop app-green
docker container rm app-green
#docker image rm app:$version
docker build -t app:$version target/docker
docker run --name app-green \
           --network docker-net \
           -d \
           -e TZ="Asia/Shanghai" \
           -v /etc/localtime:/etc/localtime:ro \
           -v /home/chess/logs:/opt/chess/logs \
           -v /home/chess/upload:/opt/chess/upload \
           app:$version
#docker logs -f app-green
\cp -f /home/chess/chess/environment/nginx/conf/upstream-green.conf /home/chess/nginx/conf/conf.d/upstream.conf
docker exec nginx bash -c "nginx -s reload"
